package com.tanhua.server.controller;

import com.tanhua.model.domain.Question;
import com.tanhua.model.dto.RecommendUserDto;
import com.tanhua.model.vo.PageResult;
import com.tanhua.model.vo.TodayBest;
import com.tanhua.server.service.MessagesService;
import com.tanhua.server.service.TanhuaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/tanhua")
public class TanhuaController {

    @Autowired
    private TanhuaService tanhuaService;



    //今日佳人
    @GetMapping("/todayBest")
    public ResponseEntity todayBest() {
        TodayBest vo = tanhuaService.todayBest();
        return ResponseEntity.ok(vo);
    }

    /**
     * 查询分页推荐好友列表
     */
    @GetMapping("/recommendation")
    public ResponseEntity recommendation(RecommendUserDto dto) {
        PageResult pr = tanhuaService.recommendation(dto);
        return ResponseEntity.ok(pr);
    }
    //查看人具体信息
    @GetMapping("/{id}/personalInfo")
    public ResponseEntity personalInfo(@PathVariable Long id){
        TodayBest info=tanhuaService.personalInfo(id);
        return ResponseEntity.ok(info);
    }
    //查看陌生人问题
    @GetMapping("/strangerQuestions")
    public ResponseEntity strangerQuestions(Long userId){
        String txt=tanhuaService.strangerQuestions(userId);
        return ResponseEntity.ok(txt);
    }

    @PostMapping("/strangerQuestions")
    public ResponseEntity replyQuestions(@RequestBody Map map){
        String userId =  map.get("userId").toString();
        Long id = Long.valueOf(userId);
        String reply =  map.get("reply").toString();
        tanhuaService.replyQuestions(id,reply);
        return ResponseEntity.ok(null);
    }

    @GetMapping("/cards")
    public ResponseEntity cards(){
        List<TodayBest> list=tanhuaService.getCards();
        return ResponseEntity.ok(list);
    }
}
